<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
    document.getElementById("demo").innerHTML = "段落已被更改。";
}
</script>
</head>
​
<body>
​
<h2>Head 中的 JavaScript</h2>
​
<p id="demo">一个段落。</p>
​
<button type="button" onclick="myFunction()">试一试</button>
​
</body>
</html>
​